package org.apache.commons.lang.file;

import java.io.*;

public class W
{

    public W()
    {
    }

    public static byte[] readFile(String filename)
        throws IOException
    {
        File file = new File(filename);
        long len = file.length();
        byte data[] = new byte[(int)len];
        FileInputStream fin = new FileInputStream(file);
        int r = fin.read(data);
        if((long)r != len)
        {
            throw new IOException((new StringBuilder("Only read ")).append(r).append(" of ").append(len).append(" for ").append(file).toString());
        } else
        {
            fin.close();
            return data;
        }
    }

    public static void writeFile(String filename, byte data[])
        throws IOException
    {
        FileOutputStream fout = new FileOutputStream(filename);
        fout.write(data);
        fout.close();
    }
}